package com.zliblike_platform.service.impl;

import com.zliblike_platform.mapper.UploadHistoryMapper;
import com.zliblike_platform.service.UploadHistoryService;
import com.zliblike_platform.vo.UploadHistoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 上传历史服务实现
 */
@Service
public class UploadHistoryServiceImpl implements UploadHistoryService {

    @Autowired
    private UploadHistoryMapper uploadHistoryMapper;

    @Override
    public Integer recordUpload(Integer userId, Integer bookId) {
        return uploadHistoryMapper.insertUploadHistory(userId, bookId);
    }

    @Override
    public List<UploadHistoryVO> getUserUploads(Integer userId, String status, int page, int size) {
        int offset = (page - 1) * size;
        return uploadHistoryMapper.selectUserUploads(userId, status, offset, size);
    }

    @Override
    public boolean updateUploadStatus(Integer uploadId, String status, String reason) {
        return uploadHistoryMapper.updateUploadStatus(uploadId, status, reason) > 0;
    }

    @Override
    public List<UploadHistoryVO> getPendingUploads(int page, int size) {
        int offset = (page - 1) * size;
        return uploadHistoryMapper.selectPendingUploads(offset, size);
    }

    @Override
    public int countUploads(String status) {
        return uploadHistoryMapper.countUploads(status);
    }
} 